package org.wmq.shopmanager.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.wmq.commonutil.result.Result;
import org.wmq.shopmanager.service.SystemUserRoleService;
import org.wmq.shopmodel.DTO.system.SystemUserRoleAssignDTO;
import org.wmq.shopmodel.DTO.system.SystemUserRoleQueryDTO;
import org.wmq.shopmodel.VO.system.SystemRoleVO;

@RestController
@RequestMapping("admin/system/system-user-role")
@RequiredArgsConstructor
public class SystemUserRoleController {
    private final SystemUserRoleService systemUserRoleService;

    @PostMapping("assignRoleToUser")
    public Result<Void> assignRoleToUser(@RequestBody SystemUserRoleAssignDTO systemUserRoleAssignDTO){
        this.systemUserRoleService.assignRoleToUser(systemUserRoleAssignDTO);
        return Result.success();
    }

    @GetMapping()
    public Result<SystemRoleVO> getAllSystemRoleAndAssignedSystemRoleBySystemUserId(@ModelAttribute SystemUserRoleQueryDTO systemUserRoleQueryDTO){
        return Result.success(this.systemUserRoleService.getAllSystemRoleAndAssignedSystemRoleBySystemUserId(systemUserRoleQueryDTO));
    }
}
